// 使用自定义宏得到结构体成员变量相对结构体起始地址的偏移量

#include <stdio.h>
#include <stdint.h>
#include "studentInfo.h"

// #define OFFSETOF(type, member) (int32_t)&(((type*)0)->member)
#define OFFSETOF(type, member) (int64_t)&(((type*)0)->member)

int main()
{
    printf("(struct StudentInfo*)0 : %p\n", (struct StudentInfo*)0);
    printf("OFFSETOF(struct StudentInfo, _name) : %d\n", OFFSETOF(struct StudentInfo, _name));
    printf("OFFSETOF(struct StudentInfo, _age) : %d\n", OFFSETOF(struct StudentInfo, _age));
    printf("OFFSETOF(struct StudentInfo, _id) : %d\n", OFFSETOF(struct StudentInfo, _id));
    printf("OFFSETOF(struct StudentInfo, _weight) : %d\n", OFFSETOF(struct StudentInfo, _weight));
    printf("OFFSETOF(struct StudentInfo, _height) : %d\n", OFFSETOF(struct StudentInfo, _height));
    printf("OFFSETOF(struct StudentInfo, _sex) : %d\n", OFFSETOF(struct StudentInfo, _sex));
}
